package com.me.study.ui.activity

import android.os.Bundle
import android.view.View
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.listener.OnItemLongClickListener
import com.me.study.R
import com.me.study.app.adapater.EmojiAdapter
import com.me.study.app.base.BaseActivity
import com.me.study.databinding.ActivityEmojiBinding
import com.me.study.viewmodel.SampleViewModel

class EmojiActivity : BaseActivity<SampleViewModel, ActivityEmojiBinding>(),
    OnItemLongClickListener {

    private val spanCount = 8
    private val emojiAdapter by lazy {
        EmojiAdapter(arrayListOf())
    }

    override fun layoutId(): Int {
        return R.layout.activity_emoji
    }

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.rvEmoji.layoutManager = GridLayoutManager(this, spanCount)
        mDatabind.rvEmoji.adapter = emojiAdapter
        emojiAdapter.setOnItemLongClickListener(this)
        mViewModel.getEmojiData(this)
    }

    override fun createObserver() {
        mViewModel.emojiDataResult.observe(this, Observer {
            emojiAdapter.addData(it)
        })
    }

    override fun onItemLongClick(
        adapter: BaseQuickAdapter<*, *>,
        view: View,
        position: Int
    ): Boolean {

        return true
    }

}